Learn R Programming

spdep (version 0.1-10)

Graph Components: Depth First Search on Neighbor Lists

Description

n.comp.nb() finds the number of disjoint connected subgraphs in the graph depicted by nb.obj - a spatial neighbours list object.

Usage

n.comp.nb(nb.obj)

Arguments

nb.obj
a neighbours list object of class nb

Value

  • A list of:
  • ncnumber of disjoint connected subgraphs
  • comp.idvector with the indices of the disjoint connected subgraphs that the nodes in nb.obj belong to

See Also

plot.nb

Examples

Run this code
data(columbus)
plot(col.gal.nb, coords, col="grey")
col2 <- droplinks(col.gal.nb, 21)
plot(col2, coords, add=TRUE)
res <- n.comp.nb(col2)
table(res$comp.id)
points(coords, col=res$comp.id, pch=16)

Run the code above in your browser using DataLab